﻿using System;
using UtfprLibrary.Windows.Forms.ComponentModel;

namespace UtfprLibrary.Windows.Forms {
    /// <summary>
    /// TODO
    /// </summary>
    internal class UtfprApplication : IUtfprApplication {
        #region IUtfprApplication Members

        #region Properties

        internal UtfprFormSplashBase _frmSplashDefault = null;
        /// <summary>
        /// TODO
        /// </summary>
        public UtfprFormSplashBase FormSplashDefault {
            get {
                if (_frmSplashDefault == null) {
                    SetFormSplashDefault<UtfprFormSplashBase>();
                }
                return _frmSplashDefault;
            }
        }

        internal UtfprFormLoginBase _frmLoginDefault = null;
        /// <summary>
        /// TODO
        /// </summary>
        public UtfprFormLoginBase FormLoginDefault {
            get {
                if (_frmLoginDefault == null) {
                    SetFormLoginDefault<UtfprFormLoginBase>();
                }

                return _frmLoginDefault;
            }
        }

        internal UtfprFormMainBase _frmMainDefault = null;
        /// <summary>
        /// TODO
        /// </summary>
        public UtfprFormMainBase FormMainDefault {
            get {
                if (_frmMainDefault == null) {
                    SetFormMainDefault<UtfprFormMainBase>();
                }

                return _frmMainDefault;
            }
        }

        internal UtfprBindingNavigatorBaseIcons _utfprBindingNavigatorIconsDefault = null;
        /// <summary>
        /// TODO
        /// </summary>
        public UtfprBindingNavigatorBaseIcons UtfprBindingNavigatorIconsDefault {
            get {
                if (_utfprBindingNavigatorIconsDefault == null) {
                    SetUtfprBindingNavigatorIconsDefault<UtfprBindingNavigatorBaseIcons>();
                }

                return _utfprBindingNavigatorIconsDefault;            
            }
        }

        internal bool _isInDebugMode = false;
        /// <summary>
        /// TODO
        /// </summary>
        public bool IsDebugMode {
            get { return _isInDebugMode; }
        }

        internal bool _isLoginEnabled = true;
        /// <summary>
        /// TODO
        /// </summary>
        public bool IsLoginEnabled {
            get { return _isLoginEnabled; }
        }

        internal bool _isSplashEnabled = true;
        /// <summary>
        /// TODO
        /// </summary>
        public bool IsSplashEnabled {
            get { return _isSplashEnabled; }
        }

        #endregion

        /// <summary>
        /// TODO
        /// </summary>
        /// <typeparam name="T"></typeparam>
        public void SetFormLoginDefault<T>() where T : UtfprFormLoginBase {
            _frmLoginDefault = Activator.CreateInstance<T>();
        }

        /// <summary>
        /// TODO
        /// </summary>
        /// <typeparam name="T"></typeparam>
        public void SetFormSplashDefault<T>() where T : UtfprFormSplashBase {
            _frmSplashDefault = Activator.CreateInstance<T>();
        }

        /// <summary>
        /// TODO
        /// </summary>
        /// <typeparam name="T"></typeparam>
        public void SetFormMainDefault<T>() where T : UtfprFormMainBase {
            _frmMainDefault = Activator.CreateInstance<T>();
        }

        public void SetUtfprBindingNavigatorIconsDefault<T>() where T : UtfprBindingNavigatorBaseIcons {
            _utfprBindingNavigatorIconsDefault = Activator.CreateInstance<T>();
        }

        /// <summary>
        /// TODO
        /// </summary>
        bool IUtfprFormLoginConfiguration.Enabled {
            get { return _isLoginEnabled; }
            set { _isLoginEnabled = value; }
        }

        /// <summary>
        /// TODO
        /// </summary>
        bool IUtfprFormSplashConfiguration.Enabled {
            get { return _isSplashEnabled; }
            set { _isSplashEnabled = value; }
        }

        #endregion

        #region Singleton

        /// <summary>
        /// TODO
        /// </summary>
        private UtfprApplication() { }

        private static UtfprApplication _utfprApplication;
        /// <summary>
        /// TODO
        /// </summary>
        public static UtfprApplication Instance {
            get {
                if (_utfprApplication == null) {
                    _utfprApplication = new UtfprApplication();
                }

                return _utfprApplication;
            }
        }

        #endregion
    }
}
